#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>

int main()
{
    //1.创建子进程，然后在子进程中野指针
    if(fork() == 0)
    {
        //子进程
        printf("i am running...\n");
        int *p = NULL;
        *p = 100;
        exit(0);
    }
    //2.父进程接收子进程状态好，进行打印
    int status = 0;
    waitpid(-1,&status,0);//1.-1表示关心所有子进程
    printf("exitcode:%d,coredump:%d,signal:%d\n",
    (status >> 8) & 0xff,(status>>7) & 1,status & 0x7f);
    return 0;
}